from django.db import models

# Create your models here.
class DataActiontime(models.Model):
    timestamp = models.DateTimeField(primary_key=True)  # The composite primary key (timestamp, name, assetnum) found, that is not supported. The first column is selected.
    name = models.CharField(max_length=255)
    assetnum = models.CharField(max_length=255)
    endpointnum = models.CharField(max_length=255, blank=True, null=True)
    location = models.CharField(max_length=255, blank=True, null=True)
    data = models.FloatField()
    tag = models.CharField(max_length=255, blank=True, null=True)
    remark = models.CharField(max_length=255, blank=True, null=True)
    createdate = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'data_actiontime'
        unique_together = (('timestamp', 'name', 'assetnum'),)


class DataFaultcode(models.Model):
    fault_id = models.IntegerField()
    timestamp = models.DateTimeField(primary_key=True)  # The composite primary key (timestamp, endpointnum, assetnum) found, that is not supported. The first column is selected.
    endpointnum = models.CharField(max_length=255)
    assetnum = models.CharField(max_length=255)
    data = models.FloatField()

    class Meta:
        managed = False
        db_table = 'data_faultcode'
        unique_together = (('timestamp', 'endpointnum', 'assetnum'),)


class DataState(models.Model):
    timestamp = models.DateTimeField(primary_key=True,)  # The composite primary key (timestamp, name, assetnum) found, that is not supported. The first column is selected.
    name = models.CharField(max_length=255)
    assetnum = models.CharField(max_length=255)
    endpointnum = models.CharField(max_length=255, blank=True, null=True)
    location = models.CharField(max_length=255, blank=True, null=True)
    data = models.FloatField()
    tag = models.CharField(max_length=255, blank=True, null=True)
    remark = models.CharField(max_length=255, blank=True, null=True)
    createdate = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'data_state'
        unique_together = (('timestamp', 'name', 'assetnum'),)


class FanucAxis(models.Model):
    timestamp = models.DateTimeField(primary_key=True)  # The composite primary key (timestamp, assetnum, channel, tag) found, that is not supported. The first column is selected.
    assetnum = models.CharField(max_length=255)
    channel = models.CharField(max_length=255)
    location = models.CharField(max_length=255, blank=True, null=True)
    tag = models.CharField(max_length=255)
    s1 = models.FloatField()
    x1 = models.FloatField()
    y1 = models.FloatField()
    z1 = models.FloatField()
    b1 = models.FloatField()
    a1 = models.FloatField()
    w1 = models.FloatField()
    v1 = models.FloatField()
    u1 = models.FloatField()
    vp = models.FloatField()
    createdate = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'fanuc_axis'
        unique_together = (('timestamp', 'assetnum', 'channel', 'tag'),)


class Faultcontent(models.Model):
    assetnum = models.CharField(max_length=255,)
    location = models.CharField(max_length=255)
    level = models.CharField(max_length=255)
    code = models.CharField(max_length=255)
    name = models.CharField(max_length=255)
    description = models.CharField(max_length=255)
    remark = models.CharField(max_length=255)
    status = models.CharField(max_length=255)
    createby = models.CharField(max_length=255)
    createdate = models.DateTimeField()
    modifyby = models.CharField(max_length=255, blank=True, null=True)
    modifydate = models.DateTimeField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'faultcontent'
        unique_together = (('assetnum', 'code'),)
        
class FanucCycle(models.Model):
    timestamp = models.DateTimeField(primary_key=True, db_comment='时间戳')  # The composite primary key (timestamp, assetnum) found, that is not supported. The first column is selected.
    name = models.CharField(max_length=255, blank=True, null=True, db_comment='数据包名称')
    assetnum = models.CharField(max_length=255, db_comment='设备编号')
    location = models.CharField(max_length=255, blank=True, null=True, db_comment='维护区域')
    spindle_load = models.FloatField(db_comment='主轴负载')
    load_x = models.FloatField(db_comment='X轴负载')
    load_y = models.FloatField(db_comment='Y轴负载')
    load_z = models.FloatField(db_comment='Z轴负载')
    load_a = models.FloatField(db_comment='A轴负载')
    load_b = models.FloatField(db_comment='B轴负载')
    codeline = models.CharField(max_length=255, blank=True, null=True, db_comment='NC程序')
    toolnum = models.CharField(max_length=255, blank=True, null=True, db_comment='刀具号')
    toollife = models.CharField(max_length=255, blank=True, null=True, db_comment='刀具寿命[使用次数]')
    coolant = models.FloatField(db_comment='高压冷却压力')

    class Meta:
        managed = False
        db_table = 'fanuc_cycle'
        unique_together = (('timestamp', 'assetnum'),)
        db_table_comment = 'Fanuc设备循环数据'




